<?php
require_once 'application/library/db/gcBasicDao.php';
require_once 'application/constant/dbConstant.php';
class dao_T_EC_M_FORMULA_ITEMDao extends gcBasicDao {
    protected $_table = "T_EC_M_FORMULA_ITEM";

    public function pbGetFormulaItemInfo($strFormulaNo) {
        $sql = "select * from T_EC_M_FORMULA_ITEM where FORMULA_NO = :FormulaNo ";
        $parameter = array("FormulaNo" => $strFormulaNo);
        $arrFormulaItemInfo = $this->select($sql, $parameter, dbReturnType::ALL);
        return $arrFormulaItemInfo;
    }

    public function pbGetFormulaItemInfoAndStockNum($strFormulaNo) {
        $sql = "select * from T_EC_M_FORMULA_ITEM as A left join T_EC_M_GOODS as B on A.GOODS_NO  = B.GOODS_NO 
                    where A.FORMULA_NO = :FormulaNo ";
        $parameter = array("FormulaNo" => $strFormulaNo);
        $arrFormulaItemInfo = $this->select($sql, $parameter, dbReturnType::ALL);
        return $arrFormulaItemInfo;
    }
    public function pbInsertFormulaItem($arrFormulaGoodsInfo) {
        $sql = "insert into T_EC_M_FORMULA_ITEM (FORMULA_NO,
                                                 GOODS_NO,
                                                 GOODS_NAME,
                                                 NUM )
                                   values(:FormulaNo,
                                          :GoodsNo,
                                          :GoodsName,
                                          :Num) ";
        $parameter = $arrFormulaGoodsInfo;
        $insertRe = $this->batchinsert($sql, $parameter);
        return $insertRe;
    }

    public function pbDeleteFormulaItem($strFormulaNo) {
        $sql = "delete from T_EC_M_FORMULA_ITEM where FORMULA_NO = :FormulaNo ";
        $parameter = array("FormulaNo" => $strFormulaNo);
        $DeleteRe = $this->delete($sql, $parameter);
        return $DeleteRe;
    }
}
